<?php
namespace App\Services\Find;
use App\Services\CommonService;
use App\Model\Infomation;
class InfomationService extends CommonService{
    /**
     * 航运咨询列表
     */
    public function InfomationList(){
        $data=Infomation::all()->where('is_recommend',1)->toArray();
        foreach($data as &$v){
            $v['desc']=mb_substr($v['content'],0,50);
        }
        return $this->success($data);
    }
    /**
     * 根据类型查询
     */
    public function InfoType($type){
        $data=Infomation::all()->where('type',$type)->toArray();
        return $this->success($data);
    }
    /**
     * 咨询详情
     */
    public function InfomationDesc($id){
        $data=Infomation::where('id',$id)->get()->toArray()[0];
        //将内容分成两部分
        $len=strlen($data['content']);
        $data['content1']=substr($data['content'],0,$len/2);
        $data['content2']=substr($data['content'],$len/2);
        unset($data['content']);
        return $this->success($data);
    }
}